﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WorkFlowBLL;

namespace QLCF.Forms.Reports
{
    public partial class frmViewStockDetail : Form
    {
        public frmViewStockDetail()
        {
            InitializeComponent();
        }
        private int StockID = -1;
        public frmViewStockDetail(int m_stockID)
        {
            InitializeComponent();
            StockID = m_stockID;
        }

        private void frmViewStockDetail_Load(object sender, EventArgs e)
        {
            string strRPSource = string.Empty;
            CtrBase trp = new CtrBase();            
            int? totalMoneyAll = 0;
            var items = trp.StockDetailGetList(StockID,ref totalMoneyAll);
            var info = trp.GetStockInfoByStockID(StockID);

            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.LocalReport.ReportEmbeddedResource = "QLCF.Reports.rptStockDetail.rdlc";

            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmDate", info.CreateDate.ToString("dd/MM/yyyy")));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmFullName", info.FullName));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmTotalMoney", info.TotalMoney == 0 ? "0 VNĐ" : info.TotalMoney.ToString("0,0") + " VNĐ"));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmNCC", info.DistributeName));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmAddress", info.DistributeAddress));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmPhone", info.DistributePhone));
            reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("prmDescription", info.Description??""));

            reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("StockDetail", items));
            reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
            reportViewer1.ZoomPercent = 100;
            reportViewer1.RefreshReport();
        }
    }
}
